VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "ClsCuenta"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

Public WithEvents orset As ClsRecordset
Attribute orset.VB_VarHelpID = -1

Public Event DataChanged()

Public codigo As String
Public codServicio As String
Public codGestion As String
Public codTipoTransaccion As String
Public numero As String
Public nombre As String

'Constructor y Destructor
Private Sub Class_Initialize()
    Set orset = New ClsRecordset
    orset.setCampos dbCampos(cue)
    orset.setTablas Array(cue)
End Sub
Private Sub Class_Terminate()
    Set orset = Nothing
End Sub
' Generic Data management methods
Public Sub consulta()
    orset.consulta
End Sub
Public Sub consultaXServicioGestion(optCodServicio As String, optCodGestion As String)
    'optcuenta deberia ser el numero de cuenta que se busca
    orset.consulta Array(cue_ser_id & "=" & optCodServicio, _
                         cue_ges_id & "=" & optCodGestion)
    If Not orset.numRegistros > 1 Then
        orset.CierraRec
    End If
End Sub
Public Sub consultaXServicioGestionTipo(optCodServicio As String, optCodGestion As String, optTipoTransaccion As String)
    orset.consulta Array(cue_ser_id & "=" & optCodServicio, _
                         cue_ges_id & "=" & optCodGestion, _
                         cue_tpt_id & "=" & optTipoTransaccion)
    If Not orset.numRegistros > 1 Then
        orset.CierraRec
    End If
End Sub
Public Sub consultaXNumero(optNumero As String, optCodGestion As String)
    orset.consulta Array(cue_numero & "='" & optNumero & "'", _
                         cue_ges_id & "=" & optCodGestion)
    orset.CierraRec
End Sub
Public Sub consultaXNombre(optNombre As String, optCodGestion As String, optNombreServicio As String)
    orset.consultaGral , Array(cue, ser, tse), _
                       Array(cue_nombre & "='" & Strings.Replace(optNombre, "'", "''") & "'", _
                             cue_ges_id & "=" & optCodGestion, _
                             cue_ser_id & "=" & ser_id, _
                             ser_nombre & "='" & Strings.Replace(optNombreServicio, "'", "''") & "'")
    orset.CierraRec
End Sub
Public Sub consultaXGestion(optCodGestion As String)
    orset.consulta Array(cue_ges_id & "=" & optCodGestion)
    Reload_members
End Sub
Public Sub consultaDatos(codig As String)
    orset.consulta Array(cue_id & "=" & codig)
    orset.CierraRec
End Sub
'para actualizacion de cuentas de asociados
Public Sub consultaXNumero_cuotas(optNumero As String, optCodGestion As String, optCodServicio As String)
    orset.consulta Array(cue_numero & "='" & optNumero & "'", _
                         cue_ges_id & "=" & optCodGestion, _
                         cue_ser_id & "=" & optCodServicio)
    orset.CierraRec
End Sub
Public Sub consultaXNombre_cuotas(optNombre As String, optCodGestion As String, optCodServicio As String)
    orset.consulta Array(cue_nombre & "='" & Strings.Replace(optNombre, "'", "''") & "'", _
                         cue_ges_id & "=" & optCodGestion, _
                         cue_ser_id & "=" & optCodServicio)
    orset.CierraRec
End Sub

Private Sub Reload_members()
    With orset
        codigo = .getDato(cue_id)
        codServicio = .getDato(cue_ser_id)
        codGestion = .getDato(cue_ges_id)
        codTipoTransaccion = .getDato(cue_tpt_id)
        nombre = .getDato(cue_nombre)
        numero = .getDato(cue_numero)
    End With
    RaiseEvent DataChanged
End Sub
'metodos de base de datos
Public Sub Nuevo(newSerId As String, newGesId As String, newTptId As String, newNumero As String, newNombre As String)
    orset.sInsert Array("", newSerId, newGesId, newTptId, newNumero, newNombre)
End Sub
Public Sub Modificar(codig As String, newSerId As String, newGesId As String, newTptId As String, newNumero As String, newNombre As String)
    orset.sUpdate Array(codig, newSerId, newGesId, newTptId, newNumero, newNombre)
End Sub
Public Sub Borrar(codig As String)
    orset.sDelete codig
End Sub
Private Sub orset_DataChanged()
    Reload_members
End Sub
